package com.yyr.callmessage.core.util;

import com.zhenzi.sms.ZhenziSmsClient;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 发送短信验证码工具类
 * @Author：
 * @Date：2021/6/27
 */
public class SMSUtil {
    public static final String AppId = "109412";
    public static final String AppASecret = "184cadb7-93e7-472c-a1b3-bbb9111224dc";
    public static final String apiUrl = "https://sms_developer.zhenzikj.com";//请求地址
    public static final String templateId = "5853";//模板Id
    public static final String expireTime = "5";//失效时间

    public static String sendVerification(String phone , String verificationCode) throws Exception {
        ZhenziSmsClient client = new ZhenziSmsClient(apiUrl , AppId , AppASecret);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("number", phone);
        params.put("templateId", templateId);//短信模板id
        String[] templateParams = new String[2];
        templateParams[0] = verificationCode;//验证码
        templateParams[1] = expireTime;//失效时间
        params.put("templateParams", templateParams);
        String result = client.send(params);
        return result;
    }
}
